/*
	Общие функции
*/

#include "defines.h"


void swap(U8 * src, U8 * dst, U8 size)
{
	U8 i=0;
	while(i<size)	
	{
			dst[i]  = src[size-i-1];
			i++;
	}
}

/*
	Переводим нашу запись в сетевой формат
*/
void h_to_n_P32(P32T * h, P32T * n)
{
			swap((U8 *)&h->ticks,(U8 *)&n->ticks,8);
			swap((U8 *)&h->adc.adc1,(U8 *)&n->adc.adc1,2);
			swap((U8 *)&h->adc.adc2,(U8 *)&n->adc.adc2,2);
			swap((U8 *)&h->adc.adc3,(U8 *)&n->adc.adc3,2);
			swap((U8 *)&h->adc.adc4,(U8 *)&n->adc.adc4,2);
	
			swap((U8 *)&h->power.powerFull,(U8 *)&n->power.powerFull,2);
			swap((U8 *)&h->power.powerActive,(U8 *)&n->power.powerActive,2);
			swap((U8 *)&h->power.voltageA,(U8 *)&n->power.voltageA,2);
			swap((U8 *)&h->power.currentA,(U8 *)&n->power.currentA,2);
			swap((U8 *)&h->power.voltageB,(U8 *)&n->power.voltageB,2);
			swap((U8 *)&h->power.currentB,(U8 *)&n->power.currentB,2);
			swap((U8 *)&h->power.voltageC,(U8 *)&n->power.voltageC,2);
			swap((U8 *)&h->power.currentC,(U8 *)&n->power.currentC,2);
}
